<?php
namespace app\common\model;


class Prizelog extends Base
{
    public static function add($userInfo, $data)
    {
        $self = new static();
        $add = [
            'uid' => $userInfo['uid'],
            'name' => $userInfo['nickname'],
            'data' => $data,
			'photo' => 'https://q1.qlogo.cn/g?b=qq&nk='.$userInfo['qq'].'&s=40&t=3046',
            'cjtime' => date('y-m-d H:i:s'),
            'date' => date('Y-m-d H:i:s'),
            'zid' => $userInfo['web_id']
        ];
        return $self->insert($add);
    }
	
    public static function search()
    {
        $page = input('post.page/d');
        $pageSize = input('post.pageSize/d');
        $page = ($page < 1) ? 1 : $page;
        $pageSize = ($pageSize < 1 || $pageSize > 50) ? 10 : $pageSize;
        $self = new static();
        $query = $self->alias('a');
        $query2 = clone $query;
        return [
            'total' => $query2->count('a.id'),
            'list' => $query->page($page, $pageSize)->order('a.date desc')->select()
        ];
    }

}